﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;

namespace OracleDAL.LogManager
{
    public class SearchLog
    {
        public DataSet getLog(string logType, string strStart, string strEnd)
        {
            DataSet ds = new DataSet();
            string strSql = "";
            if (logType == "operate")
            {
                strSql = "select USERNAME as 操作人,OPERATIONTIME as 操作时间,IPADDR as IP地址,MACADDR as MAC地址,OPERATENAME as 操作内容,OPERATERESOURCE as 操作项目,OPERATERESULT 是否成功";
                strSql += " from sec_operatelog";
                strSql += " where OPERATIONTIME between " + strStart + " and " + strEnd + "";

                ds = DBUtility.OracleHelper.Query(strSql);
            }
            else if (logType == "logon")
            {
                strSql = "select USERNAME as 登录人,USERIP as IP地址,USERMAC as MAC地址,LOGONTIME as 登录时间,LOGOUTTIME as 推出时间,LOGONSUCCEED as 是否成功 ";
                strSql += " from sec_logonlog";
                strSql += " where LOGONTIME between " + strStart + " and " + strEnd + "";

                ds = DBUtility.OracleHelper.Query(strSql);
            }
            else if (logType == "run")
            {
                strSql = "select username as 操作人,logtime as 操作时间,ip as IP地址,logtype as 类型,loginfo as 操作内容";
                strSql += " from runlog";
                strSql += " where logtime between " + strStart + " and " + strEnd + "";

                ds = DBUtility.OracleHelper.Query(strSql);
            }
            return ds;
        }

    }
}
